<?php
session_start();
include('personelDatabase.php');

class PersonelController{

	public function personellogin(){
		if(isset($_POST['PersonelID']))
			{
				$myDatabase = new PersonelDatabase();
				$myDatabase->controlLogin($_POST["PersonelID"], $_POST["password"]);
			}
	}
	public function controllPass(){
		if (isset($_POST['PersonelID']))
			{
				$myDatabase = new PErsonelDatabase();
				$myDatabase->sendPass($_POST["PersonelID"], $_POST["captcha"],$_SESSION["code"]);
			}
	}
	public function personel_logout(){
		if(isset($_SESSION["PersonelID"]))
			{
				$myDatabase = new PersonelDatabase();
				$myDatabase->controlLogout();
			}
	}
	public function profile_change(){
			
				$myDatabase = new PersonelDatabase();
				$myDatabase->controlChangeProfile($_POST["FirstName"],$_POST["LastName"],$_POST["Email"],$_POST["CellPhone_Number"],$Address=$_POST["Address"]);
			
	}
	public function password_change(){
		if(isset($_POST['CurPassword']))
			{
				$myDatabase = new PersonelDatabase();
				$myDatabase->controlChangePassword($_POST['CurPassword'], $_POST['NewPassword'], $_POST['retypeNewPassword']);
			}
	}
	
}

	if($_GET['id']==0)
	{
		$obj = new PersonelController();
		$obj->personellogin();
	}
	elseif ($_GET['id']==1)
	{
		$obj = new PersonelController();
		$obj->controllPass();
	}
	elseif($_GET['id']==2)
	{
		$obj = new PersonelController();
		$obj->personel_logout();
	}
	elseif($_GET['id']==3)
	{
		$obj = new PersonelController();
		$obj->profile_change();
	}
	elseif($_GET['id']==4)
	{
		$obj = new PersonelController();
		$obj->password_change();
	}
?>